Component({
  properties: {
    color: { //标签颜色
      type: String,
      value: '#ccc'
    },
    name: { //标签名称
      type: String,
      value: ''
    },
    value: { //红点的值
      type: [String,Number],
      value: '',
      observer(newVal){
        if(newVal > 99){
          this.setData({
            newValue:'99+'
          })
        }else{
          this.setData({
            newValue:newVal
          })
        }
      }
    },
    size: { //标签尺寸，mini，small，normal，large
      type: String,
      value: 'normal'
    },
    radius: { //圆角值
      type: [String,Number],
      value: 3
    },
    showDot: { //是否显示红点
      type: Boolean,
      value: false
    },
    
    isPlain: { //是否是镂空标签
      type: Boolean,
      value: false
    },
    showGap: { //是否是多个tag带间距
      type: Boolean,
      value: true
    },
    closable: { //是否开启关闭,开启时红点value失效不显示
      type: Boolean,
      value: false
    },
    url: { //有跳转链接的单元格
      type: String,
      value: ''
    },
    navigateTo: { //跳转方式
      type: String,
      value: ''
    }
  },
  data: {
    newValue:0
  },
  methods: {
    onClick() {
      if (this.data.url) {
        switch (this.data.navigateTo) {
          case 'redirectTo':
            wx.redirectTo({
              url: this.data.url
            });
            break;
          case 'switchTab':
            wx.switchTab({
              url: this.data.url
            });
            break;
          case 'reLaunch':
            wx.reLaunch({
              url: this.data.url
            });
            break;
          default:
            wx.navigateTo({
              url: this.data.url
            });
        }
      } else {
        this.triggerEvent('click')
      }
    },
    onClose(){
      this.triggerEvent('close');
    }
  }
})
